﻿Imports System.Data
Imports System.Data.SqlClient
Imports Sistema_InformacionNaviera.BE
Imports Sistema_InformacionNavier.UTIL

Public Class LineaDALC

    Public Function ListaLinea(ByVal objLineaBE As LineaBE) As List(Of LineaBE)


        Dim sqlListar As String
        Dim objListaLinea As New List(Of LineaBE)
        Dim objLinBE As LineaBE = Nothing
        Dim arrSqlParameter(1) As SqlParameter
        Dim ds As DataSet
        Dim dt As DataTable

        Dim blnExito As Boolean
        Dim strMensaje As String = String.Empty

        Dim objDatos As New AccesoDatos()
        Dim intI As Integer = 0

        Try

            sqlListar = "SP_Linea_List"

            arrSqlParameter(0) = New SqlParameter("@CODIGO", System.Data.SqlDbType.VarChar)
            arrSqlParameter(0).Value = objLineaBE.Codigo

            arrSqlParameter(1) = New SqlParameter("@DESCRIPCION", System.Data.SqlDbType.VarChar)
            arrSqlParameter(1).Value = objLineaBE.Descripcion


            ds = objDatos.DevuelveDataSet(sqlListar, blnExito, strMensaje, arrSqlParameter)
            dt = ds.Tables(0)


            objListaLinea = New List(Of LineaBE)()

            If dt.Rows.Count > 0 Then

                While intI < dt.Rows.Count
                    objLinBE = New LineaBE()
                    objLinBE.Codigo = dt.Rows(intI).ItemArray(0).ToString
                    objLinBE.Descripcion = dt.Rows(intI).ItemArray(1).ToString

                    intI = intI + 1

                    objListaLinea.Add(objLinBE)
                End While
            End If


        Catch ex As Exception
            MsgBox(ex.Message, vbCritical, "Error del sistema")
            Return Nothing
            Exit Function
        End Try

        Return objListaLinea

    End Function



End Class
